{% load widget_tweaks %}
{{ projectFU.management_form }}
<script>
	if (typeof sessvars.sessionObj == 'undefined'){sessvars.sessionObj = {'projectId': $('select#id_name').find("option:selected").val()};}
	if (typeof sessvars.sessionObj != 'undefined'){
		if (sessvars.sessionObj['projectId'] == ""){sessvars.sessionObj['projectId'] = $('select#id_name').find("option:selected").val();}
		else {
			for (var i=0;i<document.getElementById('id_name').options.length;i++) {
				if (document.getElementById('id_name').options[i].value == sessvars.sessionObj['projectId'])
					{document.getElementById('id_name').options[i].selected = true;}
			}
		}
	}
	$('#psubId').val(sessvars.sessionObj['projectId'])
	
	$('form#projectSubmit').ajaxForm({
		success: function(data){
				//console.log(data);
				$('#buildingForm').html(data);
				$('#success').fadeIn().delay(2000).fadeOut(1000);
				var newF = $('#newF').val()
				if (newF != ''){
					sessvars.sessionObj = {'projectId': newF}
					window.location.reload(true)
				}    
			}
	})
	$('#startTimeBtn').click(
	  	function(e) {
    		$('#id_start_date').AnyTime_noPicker().AnyTime_picker({format: "%Y-%m-%d"}).focus();
        	e.preventDefault();
      	} 
     );
     $('#endTimeBtn').click(
	  	function(e) {
    		$('#id_end_date').AnyTime_noPicker().AnyTime_picker({format: "%Y-%m-%d"}).focus();
        	e.preventDefault();
      	} 
     );
</script>
<form method="post" action="submit" id="projectSubmit">
	<div class='row' style="margin-bottom: 15px">
		<div class="span4">
			<input type="hidden" id="newF" value="{{ newF }}"\>
			<input type="hidden" name="projectId" id="psubId"\>	
			
			<legend>Project information</legend>
			<label class="control-label">Group *</label>
			<div class="controls">{{ projectFU.group|add_class:"span2" }}{{ projectFU.group.errors }}</div>
			<label class="control-label">Project short name *</label>
			<div class="controls">{{ projectFU.name|add_class:"span2" }}{{ projectFU.name.errors }}</div>
			<label class="control-label">Building name *</label>
			<div class="controls">{{ projectFU.building|add_class:"span3" }}{{ projectFU.building.errors }}</div>
			<label class="control-label">Project start date *</label>
			<div class="controls">{{ projectFU.start_date|add_class:"span2" }}{{ projectFU.start_date.errors }}
				<button id="startTimeBtn">
					<img src="/static/pmp/img/calendar.png" alt="[calendar icon]"/>
				</button>
			</div>
			<label class="control-label">End date</label>
			<div class="controls">{{ projectFU.end_date|add_class:"span2" }}{{ projectFU.end_date.errors }}
				<button id="endTimeBtn">
		    		<img src="/static/pmp/img/calendar.png" alt="[calendar icon]"/>
		  		</button>
		  	</div>
		  	<label class="control-label">Floors studied (select multiple using CTRL key)</label>
		  	<div class="controls">{{ projectFU.floors|add_class:"span1"|attr:"size:7" }}{{ projectFU.floors.errors }}</div>
			<p style="font-size: 11px">*Required fields</p>
		</div><!--span-->
		<div class="span4">
			<legend>Location information</legend>
			<label class="control-label">Location description</label>
			<div class="controls">{{ projectFU.location_description|add_class:"span2" }}{{ projectFU.location_description.errors }}</div>
			<label class="control-label">City</label>
			<div class="controls">{{ projectFU.city|add_class:"span2" }}{{ projectFU.city.errors }}</div>		
			<label class="control-label">State</label>
			<div class="controls">{{ projectFU.state|add_class:"input-mini" }}{{ projectFU.state.errors }}</div>
			<label class="control-label">Zipcode</label>
			<div class="controls">{{ projectFU.zipcode|add_class:"span1" }}{{ projectFU.zipcode.errors }}</div>
			<label class="control-label">Country</label>
			<div class="controls">{{ projectFU.country|add_class:"span2" }}{{ projectFU.country.errors }}</div>
			<label class="control-label">Timezone</label>
			<div class="controls">{{ projectFU.timezone|add_class:"span3" }}{{ projectFU.timezone.errors }}</div>	
		</div><!--span-->
	</div><!--row-->	
	<div class='row' style="margin-bottom: 15px">
		<div class="span4">
			<legend>Basic building information</legend>
			<label class="control-label">Building type</label>
			<div class="controls">{{ projectFU.building_type|add_class:"span2" }}{{ projectFU.building_type.errors }}</div>
			<label class="control-label">Gross floor area (sf)</label>
			<div class="controls">{{ projectFU.gross_floor_area|add_class:"span1" }}{{ projectFU.gross_floor_area.errors }}</div>
			<label class="control-label">Above ground conditioned floors</label>
			<div class="controls">{{ projectFU.conditioned_floors_ag|add_class:"span1" }}{{ projectFU.conditioned_floors_ag.errors }}</div>
			<label class="control-label">Below ground conditioned floors</label>
			<div class="controls">{{ projectFU.conditioned_floors_bg|add_class:"span1" }}{{ projectFU.conditioned_floors_bg.errors }}</div>
			<label class="control-label">Primary construction year</label>
			<div class="controls">{{ projectFU.primary_construction_year|add_class:"span1" }}{{ projectFU.primary_construction_year.errors }}</div>
			<label class="control-label">Secondary construction year</label>
			<div class="controls">{{ projectFU.secondary_construction_year|add_class:"span1" }}{{ projectFU.secondary_construction_year.errors }}</div>
			<label class="control-label">Commissioning level</label>
			<div class="controls">{{ projectFU.commissioning_level|add_class:"span2" }}{{ projectFU.commissioning_level.errors }}</div>
			<p style="font-size: 11px">*All fields required</p>
		</div>
		<div class="span4">
		<legend>Construction details</legend>
			<label class="control-label">Average floor to floor height (ft)</label>
			<div class="controls">{{ projectFU.average_flr_flr_height|add_class:"span1" }}{{ projectFU.average_flr_flr_height.errors }}</div>
			<label class="control-label">Average floor to ceiling height (ft)</label>
			<div class="controls">{{ projectFU.average_flr_clg_height|add_class:"span1" }}{{ projectFU.average_flr_clg_height.errors }}</div>
			<label class="control-label">Primary window type</label>
			<div class="controls">{{ projectFU.primary_window_type|add_class:"span2" }}{{ projectFU.primary_window_type.errors }}</div>
			<label class="control-label">Window to wall ratio</label>
			<div class="controls">{{ projectFU.window_wall_ratio|add_class:"span2" }}{{ projectFU.window_wall_ratio.errors }}</div>
			<label class="control-label">Primary floor construction</label>
			<div class="controls">{{ projectFU.primary_floor_construction|add_class:"span2" }}{{ projectFU.primary_floor_construction.errors }}</div>
			<label class="control-label">Primary wall construction</label>
			<div class="controls">{{ projectFU.primary_wall_construction|add_class:"span2" }}{{ projectFU.primary_wall_construction.errors }}</div>
			<label class="control-label">Primary ceiling construction</label>
			<div class="controls">{{ projectFU.primary_ceiling_construction|add_class:"span2" }}{{ projectFU.primary_ceiling_construction.errors }}</div>
		</div><!--span-->
	</div><!--row-->
	<div class='row' style="margin-bottom: 15px">
		<div class="span4">
			<legend>Detailed building information</legend> 			
			<label class="control-label">HVAC system attributes (select multiple using CTRL key)</label>{{ projectFU.hvac_attributes|add_class:"span4"|attr:"size:7" }}{{ projectFU.hvac_attributes.errors }}
			<label class="control-label">Lighting system attributes (select multiple using CTRL key)</label>{{ projectFU.lighting_attributes|add_class:"span4"|attr:"size:7" }}{{ projectFU.lighting_attributes.errors }}
			<label class="control-label">Envelope attributes (select multiple using CTRL key)</label>{{ projectFU.envelope_attributes|add_class:"span4"|attr:"size:4" }}{{ projectFU.envelope_attributes.errors }}
		</div>
		<div class="span4">
			<legend>Owner and occupancy details</legend>
			<label class="control-label">Owner</label>
			<div class="controls">{{ projectFU.owner|add_class:"span3" }}{{ projectFU.owner.errors }}</div>
			<label class="control-label">Owner occupied</label>
			<div class="controls">{{ projectFU.owner_occupied|add_class:"span1" }}{{ projectFU.owner_occupied.errors }}</div>
			<label class="control-label">Government occupied</label>
			<div class="controls">{{ projectFU.government_occupied|add_class:"span1" }}{{ projectFU.government_occupied.errors }}</div>
			<label class="control-label">Tenancy</label>
			<div class="controls">{{ projectFU.tenancy|add_class:"span1" }}{{ projectFU.tenancy.errors }}</div>
			<label class="control-label">Average # male occupants</label>
			<div class="controls">{{ projectFU.avg_male_occupants|add_class:"span1" }}{{ projectFU.avg_male_occupants.errors }}</div>
			<label class="control-label">Average # female occupants</label>
			<div class="controls">{{ projectFU.avg_female_occupants|add_class:"span1" }}{{ projectFU.avg_female_occupants.errors }}</div>
		</div>
	</div>
	<div class='row' style="margin-bottom: 15px">
		<div class="span4">
			<legend>LEED Information</legend>
			<label class="control-label">LEED product</label>
			<div class="controls">{{ projectFU.leed_product|add_class:"span2" }}{{ projectFU.leed_product.errors }}</div>
			<label class="control-label">LEED version</label>
			<div class="controls">{{ projectFU.leed_version|add_class:"span1" }}{{ projectFU.leed_version.errors }}</div>
			<label class="control-label">LEED rating</label>
			<div class="controls">{{ projectFU.leed_rating|add_class:"span2" }}{{ projectFU.leed_rating.errors }}</div>
			<label class="control-label">Emissions information (select multiple using CTRL key)</label>
			<div class="controls">{{ projectFU.emissions_attributes|add_class:"span4"|attr:"size:7" }}{{ projectFU.emissions_attributes.errors }}</div>
		</div>
		<div class="span4">
			<legend>Schedule</legend>
			<div class='control-group'>
				<label class="control-label">Mon-Fri start hour \ end hour</label>
				<div class='controls form-inline'>
					{{ projectFU.mon_fri_start_hour|add_class:"span1"|attr:"placeholder:Start" }}{{ projectFU.mon_fri_start_hour.errors }}
					{{ projectFU.mon_fri_end_hour|add_class:"span1"|attr:"placeholder:End" }}{{ projectFU.mon_fri_end_hour.errors }}
				</div>
			</div>
			<div class='control-group'>
				<label class="control-label">Sat/Sun start hour \ end hour</label>
				<div class='controls form-inline'>
					{{ projectFU.sat_sun_start_hour|add_class:"span1"|attr:"placeholder:Start" }}{{ projectFU.sat_sun_start_hour.errors }}
					{{ projectFU.sat_sun_end_hour|add_class:"span1"|attr:"placeholder:End" }}{{ projectFU.sat_sun_end_hour.errors }}
				</div>
			</div>
			<div class='control-group'>
				<label class="control-label">Occupied cooling \ heating setpoint</label>
				<div class='controls form-inline'>
					{{ projectFU.occupied_cooling_sp|add_class:"span1"|attr:"placeholder:Cool" }}{{ projectFU.occupied_cooling_sp.errors }}
					{{ projectFU.occupied_heating_sp|add_class:"span1"|attr:"placeholder:Heat" }}{{ projectFU.occupied_heating_sp.errors }}
				</div>
			</div>
			<div class='control-group'>
				<label class="control-label">Unoccupied cooling \ heating setpoint</label>
				<div class='controls form-inline'>
					{{ projectFU.unoccupied_cooling_sp|add_class:"span1"|attr:"placeholder:Cool" }}{{ projectFU.unoccupied_cooling_sp.errors }}
					{{ projectFU.unoccupied_heating_sp|add_class:"span1"|attr:"placeholder:Heat" }}{{ projectFU.unoccupied_heating_sp.errors }}
				</div>
			</div>
		</div>
	</div>
	<div class='row'>
		<div class="span4">
			<legend>Design team</legend>
			<label class="control-label">Primary architect</label>
			<div class="controls">{{ projectFU.primary_architect|add_class:"span3" }}{{ projectFU.primary_architect.errors }}</div>
			<label class="control-label">Secondary architect</label>
			<div class="controls">{{ projectFU.secondary_architect|add_class:"span3" }}{{ projectFU.secondary_architect.errors }}</div>
			<label class="control-label">Mechanical engineer</label>
			<div class="controls">{{ projectFU.mechanical_engineer|add_class:"span3" }}{{ projectFU.mechanical_engineer.errors }}</div>
			<label class="control-label">Electrical engineer</label>
			<div class="controls">{{ projectFU.electrical_engineer|add_class:"span3" }}{{ projectFU.electrical_engineer.errors }}</div>
			<label class="control-label">Structural engineer</label>
			<div class="controls">{{ projectFU.structural_engineer|add_class:"span3" }}{{ projectFU.structural_engineer.errors }}</div>
			<label class="control-label">Lanscape architect</label>
			<div class="controls">{{ projectFU.landscape_architect|add_class:"span3" }}{{ projectFU.landscape_architect.errors }}</div>
			<label class="control-label">General contractor</label>
			<div class="controls">{{ projectFU.general_contractor|add_class:"span3" }}{{ projectFU.general_contractor.errors }}</div>
			<br>	
			<p><input type="submit" class="btn" value="Save changes" /><span id="success"><strong>&nbsp;&nbsp;{{ saveStatus }}</strong></span></p>
		</div><!--span-->
		<div class="span4">
			<legend>Additional building/project notes</legend>
			{{ projectFU.notes|add_class:"span5" }}{{ projectFU.notes.errors }}<br>	
			<div class="control-group">
				<label class="control-label">Image</label>
				<div class="controls form-inline">{{ projectFU.image }}{{ projectFU.image.errors }}</div>			
			</div>
		</div><!--span-->
		
	</div><!--row-->
    
</form>
